package com.example.forjava.model.builder.service;

import com.example.forjava.model.builder.HouseBuilder;
import com.example.forjava.model.builder.entity.House;

//指挥者
public class HouseDirector {
    HouseBuilder houseBuilder = null;
    //构造器创建builder对象
    public HouseDirector(HouseBuilder houseBuilder) {
        this.houseBuilder = houseBuilder;
    }
    //通过set方法设置对象属性
    public void setHouseBuilder(HouseBuilder houseBuilder) {
        this.houseBuilder = houseBuilder;
    }
    //建造房屋的流程交给指挥者
    public House constructHouse() {
        houseBuilder.buildBasic();
        houseBuilder.buildWalls();
        houseBuilder.roofed();
        return houseBuilder.buildHouse();
    }
}
